package com.itheima.consumer.config;

import lombok.extern.slf4j.Slf4j;
import org.springframework.amqp.core.*;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;

/**
 * @Author: fanYuLe
 * @CreateTime: 2025-04-03  15:18
 * @Description:
 */
@Slf4j
@Configuration
public class DelayExchangeConfig {


    @Bean
    public DirectExchange delayExchange(){
        return ExchangeBuilder.directExchange("delay.direct")
                .delayed()
                .durable(true)
                .build();
    }

    @Bean
    public Queue delayedQueue(){
        return new Queue("delay.queue");
    }

    @Bean
    public Binding delayQueueBinding(Queue delayedQueue,DirectExchange delayExchange){
        return BindingBuilder.bind(delayedQueue).to(delayExchange).with("delay");
    }
}
